library(data.table)
library(ggplot2)
library(here)
library(gridExtra)
library(grid)
library(gtable)
library(magrittr)
library(RcppArmadillo)
library(snow)
library(doSNOW)
library(foreach)
library(tcltk)
# min sample size
n_min = 10
n_iteration = 1000
# source null function
dir = here()
setwd(dir)
source("null_function.R")
# world bank data
wd = gsub("null_growth_model", "", dir)
setwd(wd)
d = fread("wdi.csv")
d$EG.USE.PCAP.KG.OE = d$EG.USE.PCAP.KG.OE*4.187/100
# fossil fuel use vs employment
###################################################
x = log(d$SL.SRV.EMPL.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_model])
slope_dist = unlist(model[(n_model+1):(2*n_model)])
library(data.table)
library(ggplot2)
library(here)
library(gridExtra)
library(grid)
library(gtable)
library(magrittr)
library(RcppArmadillo)
library(snow)
library(doSNOW)
library(foreach)
library(tcltk)
# min sample size
n_min = 10
n_iteration = 5000
# source null function
dir = here()
setwd(dir)
source("null_function.R")
# world bank data
wd = gsub("null_growth_model", "", dir)
setwd(wd)
d = fread("wdi.csv")
d$EG.USE.PCAP.KG.OE = d$EG.USE.PCAP.KG.OE*4.187/100
# fossil fuel use vs employment
###################################################
x = log(d$SL.SRV.EMPL.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_model])
slope_dist = unlist(model[(n_model+1):(2*n_model)])
slope_mean_dist = unlist(model[1:n_iteration])
slope_dist = unlist(model[(n_iteration+1):(2*n_iteration)])
max(slope_mean_dist)
1/5000
hist(slope_mean_dist)
max(slope_mean_dist, breaks = 1000)
max(slope_mean_dist, breaks = 1000)
hist(slope_mean_dist, breaks = 1000)
hist(slope_mean_dist, breaks = 100)
plot(density(slope_mean_dist))
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
test = rnorm(10^6, m, s)
lines(density(test))
plot(density(slope_mean_dist), log = "y")
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
test = rnorm(10^6, m, s)
lines(density(test))
ks.test(slope_mean_dist, test)
pnorm(1, m, s)
pnorm(0, m, s)
pnorm(0.8, m, s)
pnorm(0.8, m, s)/10^10
pnorm(0.8, m, s) - 1
pnorm(0.3, m, s)
pnorm(0.5, m, s)
pnorm(0.4, m, s)
test = pnorm(0.4, m, s)
test = pnorm(0.8, m, s)
test = pnorm(0.7, m, s)
test = pnorm(0.7, m, s)
test = pnorm(0.6, m, s)
test = pnorm(0.6, m, s)
test = pnorm(0.5, m, s)
options( scipen = 20 )
test = pnorm(0.5, m, s)
options( scipen = 20 )
pnorm(0.5, m, s)
options( scipen = 20 )
pnorm(0.3, m, s)
options( scipen = 20 )
test = pnorm(0.3, m, s)
formatC(test, format = "e", digits = 2)
options( scipen = 20 )
test = pnorm(0.2, m, s)
formatC(test, format = "e", digits = 2)
options( scipen = 20 )
test = pnorm(0.2, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.2, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.5, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.9, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.8, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.6, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.5, m, s)
formatC(test, format = "e", digits = 10)
options( scipen = 20 )
test = 1 -pnorm(0.6, m, s)
options( scipen = 20 )
test = 1 -pnorm(0.5, m, s)
formatC(test, format = "e", digits = 10)
test = 1 -pnorm(0.5, m, s)
formatC(test, format = "e", digits = 10)
library(data.table)
library(ggplot2)
library(here)
library(gridExtra)
library(grid)
library(gtable)
library(magrittr)
library(RcppArmadillo)
library(snow)
library(doSNOW)
library(foreach)
library(tcltk)
# min sample size
n_min = 10
n_iteration = 5000
# source null function
dir = here()
setwd(dir)
source("null_function.R")
# world bank data
wd = gsub("null_growth_model", "", dir)
setwd(wd)
d = fread("wdi.csv")
d$EG.USE.PCAP.KG.OE = d$EG.USE.PCAP.KG.OE*4.187/100
# fossil fuel use vs employment
###################################################
x = log(d$SL.SRV.EMPL.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_iteration])
slope_dist = unlist(model[(n_iteration+1):(2*n_iteration)])
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
test = 1 -pnorm(0.5, m, s)
formatC(test, format = "e", digits = 10)
library(data.table)
library(ggplot2)
library(here)
library(gridExtra)
library(grid)
library(gtable)
library(magrittr)
library(RcppArmadillo)
library(snow)
library(doSNOW)
library(foreach)
library(tcltk)
# min sample size
n_min = 10
n_iteration = 1000
# source null function
dir = here()
setwd(dir)
source("null_function.R")
# world bank data
wd = gsub("null_growth_model", "", dir)
setwd(wd)
d = fread("wdi.csv")
d$EG.USE.PCAP.KG.OE = d$EG.USE.PCAP.KG.OE*4.187/100
# fossil fuel use vs employment
###################################################
x = log(d$SL.SRV.EMPL.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_iteration])
slope_dist = unlist(model[(n_iteration+1):(2*n_iteration)])
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
p_fossil_employment = 1 -pnorm(0.5, m, s)
# CO2 emissions per capita
#############################################################
x = log(d$NV.SRV.TETC.ZS)
y = log(d$EN.ATM.CO2E.PC)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_iteration])
slope_dist = unlist(model[(n_iteration+1):(2*n_iteration)])
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
p_carbon_employment = 1 -pnorm(0.5, m, s)
x = log(d$NV.SRV.TETC.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
x = log(d$NV.SRV.TETC.ZS)
y = log(d$EG.USE.PCAP.KG.OE*d$EG.USE.COMM.FO.ZS/100)
model = null_function(x, y, n_sample, n_iteration)
slope_mean_dist = unlist(model[1:n_iteration])
slope_dist = unlist(model[(n_iteration+1):(2*n_iteration)])
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
p_fossil_value = 1 -pnorm(slope_test, m, s)
n_iteration = 1000
slope_test = 0.5
s = sd(slope_mean_dist)
m = mean(slope_mean_dist)
p_fossil_value = 1 -pnorm(slope_test, m, s)
p_fossil_value*10^10
source('~/Desktop/BERQ_revision_2/Supplementary Material/data/world bank/null_growth_model/absolute_null.R')
source('~/Desktop/BERQ_revision_2/Supplementary Material/figures/absolute_stats.R')
# export
############################################
test_name= c("",
"Fossil Fuel Use vs. Service Employment",
"C02 Emissions vs. Service Employment",
"Fossil Fuel Use vs. Service Value Added",
"C02 Emissions vs. Service Value Added"
)
test_name= c(     "Fossil Fuel Use vs. Service Employment",
"C02 Emissions vs. Service Employment",
"Fossil Fuel Use vs. Service Value Added",
"C02 Emissions vs. Service Value Added"
)
results = c(p_fossil_employment, p_carbon_employment, p_fossil_value, p_carbon_value)
test_name= c(     "Fossil Fuel Use vs. Service Employment",
"C02 Emissions vs. Service Employment",
"Fossil Fuel Use vs. Service Value Added",
"C02 Emissions vs. Service Value Added")
output = data.table(test_name, p_value = results)
output = data.table(test_name, p_value_less_than = results)
source('~/Desktop/BERQ_revision_2/Supplementary Material/data/world bank/null_growth_model/absolute_null.R')
